package com.authsphere.security.authorization;


import com.authsphere.security.token.common.AccessToken;

import java.io.Serial;
import java.io.Serializable;

/**
 * @program: AuthSphere
 * @description:
 * @author: YuKai Fan
 * @create: 2025/3/13 11:38
 **/
public class AuthSphereResponse implements Serializable {
    @Serial
    private static final long serialVersionUID = -4603169696627485995L;

    private Integer code;

    private String message;

    private boolean success;

    private AccessToken accessToken;

    private Object principal;

    public AuthSphereResponse() {
    }

    public AuthSphereResponse(AccessToken accessToken, Object principal) {
        this.accessToken = accessToken;
        this.principal = principal;
    }

    public AccessToken getAccessToken() {
        return accessToken;
    }

    public void setAccessToken(AccessToken accessToken) {
        this.accessToken = accessToken;
    }

    public Object getPrincipal() {
        return principal;
    }

    public void setPrincipal(Object principal) {
        this.principal = principal;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }


    public static final class Builder {
        private Integer code;
        private String message;
        private boolean success;
        private AccessToken accessToken;
        private Object principal;

        private Builder() {
        }

        public static Builder builder() {
            return new Builder();
        }

        public Builder code(Integer code) {
            this.code = code;
            return this;
        }

        public Builder message(String message) {
            this.message = message;
            return this;
        }

        public Builder success(boolean success) {
            this.success = success;
            return this;
        }

        public Builder accessToken(AccessToken accessToken) {
            this.accessToken = accessToken;
            return this;
        }

        public Builder principal(Object principal) {
            this.principal = principal;
            return this;
        }

        public AuthSphereResponse build() {
            AuthSphereResponse authSphereResponse = new AuthSphereResponse();
            authSphereResponse.setCode(code);
            authSphereResponse.setMessage(message);
            authSphereResponse.setSuccess(success);
            authSphereResponse.setAccessToken(accessToken);
            authSphereResponse.setPrincipal(principal);
            return authSphereResponse;
        }
    }
}
